<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var findContentChildren = function(g, s) {
				g.sort((a, b) => a - b);
				s.sort((a, b) => a - b);
				let ans = 0;
				let i = g.length - 1;
				let j = s.length - 1;
				while (i >= 0 && j >= 0) {
					if (s[j] >= g[i]) {
						j--;
						i--;
						ans++;
					} else {
						i--;
					}
				}
				return ans;
			};
			console.log(findContentChildren([1, 2], [1, 2, 3]));
		</script>
	</body>
</html>
